From: Wei Liu Date: Thu, 8 Jun 2017 16:09:49 +0000 (+0100) Subject: x86: move hypercall_page_initialise_ring1_kernel X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~1918 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=bc0c48953c55bfeef22568b7115bb426046c6f01;p=xen.git x86: move hypercall_page_initialise_ring1_kernel Signed-off-by: Wei Liu Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index 4f2c2cde12..f79f7eef62 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -290,6 +290,36 @@ void hypercall_page_initialise_ring3_kernel(void *hypercall_page) *(u16 *)(p+ 9) = 0x050f; /* syscall */ } +void hypercall_page_initialise_ring1_kernel(void *hypercall_page) +{ + void *p = hypercall_page; + unsigned int i; + + /* Fill in all the transfer points with template machine code. */ + + for ( i = 0; i < (PAGE_SIZE / 32); i++, p += 32 ) + { + if ( i == __HYPERVISOR_iret ) + continue; + + *(u8 *)(p+ 0) = 0xb8; /* mov $,%eax */ + *(u32 *)(p+ 1) = i; + *(u16 *)(p+ 5) = (HYPERCALL_VECTOR << 8) | 0xcd; /* int $xx */ + *(u8 *)(p+ 7) = 0xc3; /* ret */ + } + + /* + * HYPERVISOR_iret is special because it doesn't return and expects a + * special stack frame. Guests jump at this transfer point instead of + * calling it. + */ + p = hypercall_page + (__HYPERVISOR_iret * 32); + *(u8 *)(p+ 0) = 0x50; /* push %eax */ + *(u8 *)(p+ 1) = 0xb8; /* mov $__HYPERVISOR_iret,%eax */ + *(u32 *)(p+ 2) = __HYPERVISOR_iret; + *(u16 *)(p+ 6) = (HYPERCALL_VECTOR << 8) | 0xcd; /* int $xx */ +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/x86_64/compat/traps.c b/xen/arch/x86/x86_64/compat/traps.c index 1751ec67e8..f485299c88 100644 --- a/xen/arch/x86/x86_64/compat/traps.c +++ b/xen/arch/x86/x86_64/compat/traps.c @@ -374,37 +374,6 @@ int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps) return rc; } -static void hypercall_page_initialise_ring1_kernel(void *hypercall_page) -{ - char *p; - int i; - - /* Fill in all the transfer points with template machine code. */ - - for ( i = 0; i < (PAGE_SIZE / 32); i++ ) - { - if ( i == __HYPERVISOR_iret ) - continue; - - p = (char *)(hypercall_page + (i * 32)); - *(u8 *)(p+ 0) = 0xb8; /* mov $,%eax */ - *(u32 *)(p+ 1) = i; - *(u16 *)(p+ 5) = (HYPERCALL_VECTOR << 8) | 0xcd; /* int $xx */ - *(u8 *)(p+ 7) = 0xc3; /* ret */ - } - - /* - * HYPERVISOR_iret is special because it doesn't return and expects a - * special stack frame. Guests jump at this transfer point instead of - * calling it. - */ - p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32)); - *(u8 *)(p+ 0) = 0x50; /* push %eax */ - *(u8 *)(p+ 1) = 0xb8; /* mov $__HYPERVISOR_iret,%eax */ - *(u32 *)(p+ 2) = __HYPERVISOR_iret; - *(u16 *)(p+ 6) = (HYPERCALL_VECTOR << 8) | 0xcd; /* int $xx */ -} - /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/hypercall.h b/xen/include/asm-x86/hypercall.h index 5631cf2694..3eb4a8db89 100644 --- a/xen/include/asm-x86/hypercall.h +++ b/xen/include/asm-x86/hypercall.h @@ -27,6 +27,7 @@ extern const hypercall_args_t hypercall_args_table[NR_hypercalls]; void pv_hypercall(struct cpu_user_regs *regs); void hypercall_page_initialise_ring3_kernel(void *hypercall_page); +void hypercall_page_initialise_ring1_kernel(void *hypercall_page); /* * Both do_mmuext_op() and do_mmu_update():